package ipdesk.model.analysis.action;

import ipdesk.model.analysis.bean.AnalysisConsultBean;
import ipdesk.model.analysis.dao.AnalysisConsultDao;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;

import ecg.util.Time;

public class AnalysisConsultAction extends ActionSupport implements Preparable, ModelDriven<AnalysisConsultBean>
{
	private AnalysisConsultBean analysisConsultBean;
	private List<AnalysisConsultBean> analysisConsultList;
	
	
	public String execute() throws Exception
	{
		String startDt	= "";
		String endDt	= "";
		
		if(analysisConsultBean.getStartDt() == null || "".equals(analysisConsultBean.getStartDt())){
			startDt	= Time.getYearMonthDayWithDash();
			// 값이 없는경우에는 시작일자는 01일을 시작값으로 한다.
			startDt = startDt.substring(0, 5);
			System.out.println("StartDT :: "+startDt);
			String startDay = "01-01";
			startDt = startDt.concat(startDay);
			System.out.println("startDt end :: "+startDt);
			analysisConsultBean.setStartDt(startDt);
		}
		
		if(analysisConsultBean.getEndDt() == null || "".equals(analysisConsultBean.getEndDt())){
			endDt	= Time.getYearMonthDayWithDash();
			analysisConsultBean.setEndDt(endDt);
		}
		
		
		
		analysisConsultList = AnalysisConsultDao.getInstance().getAnalysisConsultList(analysisConsultBean);
		
		//System.out.println("here is .....................................................................");
		return SUCCESS;
	}

	public void prepare() throws Exception {
		analysisConsultBean = new AnalysisConsultBean();
		
	}

	public AnalysisConsultBean getModel() {

		return analysisConsultBean;
	}



	public List<AnalysisConsultBean> getAnalysisConsultList() {
		return analysisConsultList;
	}
}

